//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics.Contracts;

using ProjectBase.Core.Diagnostics;

namespace ProjectBase.Core.Service
{
    /// <summary>
    ///     Provides a general interface for objet Factory.
    /// </summary>
    [ContractClass(typeof(Diagnostics.FactoryProvider))]
    public interface IFactoryProvider : IServiceProvider
    {
        /// <summary>
        ///     Creates the new instance of the type T
        /// </summary>
        /// <typeparam name = "T">Interface (naming conventions for implementing class)
        ///     or class with public constructor without parameters</typeparam>
        /// <param name="name">A name registered by the IFactoryProvider implementor</param>
        /// <param name="implementor">type implementing T to be returned</param>
        /// <returns>instance of requested type</returns>
        T CreateInstance<T>(string name = null, Type implementor = null)
            where T : class, IService;

        /// <summary>
        ///     Creates the new instance of the type T
        /// </summary>
        /// <param name = "type">Interface (naming conventions for implementing class)
        ///     or class with public constructor without parameters</param>
        /// <param name="name">A name registered by the IFactoryProvider implementor</param>
        /// <param name="implementor">type implementing T to be returned</param>
        /// <returns>instance of requested type</returns>
        object CreateInstance(Type type, string name = null, Type implementor = null);

        /// <summary>
        ///     Creates the list of instance implementing asked type T.
        ///     Empty list for not registered types is returned.
        /// </summary>
        /// <typeparam name = "T">Interface (naming conventions for implementing class)
        ///     or class with public constructor without parameters</typeparam>
        /// <returns>not null list of requested instances</returns>
        IEnumerable<T> CreateInstances<T>()
            where T : class, IService;

        /// <summary>
        ///     Injects dependencies via setters. Intended for 'external framework' created instances, e.g. aspx Page
        /// </summary>
        void Enrich<T>(T instance);
    }
}